//
//  BaseViewController.m
//  FreshMember
//
//  Created by qyc on 2019/4/8.
//  Copyright © 2019年 qyc. All rights reserved.
//

#import "BaseViewController.h"

@interface BaseViewController ()
@property (nonatomic,strong) UIView *navView;
@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.dataArray = [[NSMutableArray alloc] init];
    self.page = 1;
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    BaseViewController *topView = (BaseViewController *)self.navigationController.topViewController;
    NSString *stringName = NSStringFromClass([topView class]);
    NSLog(@"%@", stringName);
}


#pragma mark - Methods
- (void)configNavigationTitle:(NSString *)title {
    
    [_navView removeFromSuperview];
    
    if (!_navView) {
        _navView = [[UIView alloc] initWithFrame:CGRectMake(0 , 0, kWindowW, k_Height_NavBar)];
        _navView.backgroundColor = UIColorFromRGB(0x272936);
        [self.view addSubview:_navView];
        
        UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
        backButton.frame = CGRectMake(0, k_Height_NavBar - 40, 35, 35);
        [backButton addTarget:self action:@selector(popButtonClicked) forControlEvents:UIControlEventTouchUpInside];
        [backButton setTitle:@"" forState:UIControlStateNormal];
        [backButton setImage:[UIImage imageNamed:@"btn_back"] forState:UIControlStateNormal];
        [_navView addSubview:backButton];
        
        UILabel *titleLabel = [UILabel new];
        titleLabel.text = title;
        titleLabel.font = [UIFont systemFontOfSize:18];
        titleLabel.textColor = UIColorFromRGB(0xffffff);
        [titleLabel setTextAlignment:NSTextAlignmentCenter];
        titleLabel.frame = CGRectMake(50, k_Height_NavBar - 35, kWindowW - 100, 25);
        [_navView addSubview:titleLabel];
    }
}

- (void)configDefaultNavigationTitle:(NSString *)title isLine:(BOOL)isLine {
    
    [_navView removeFromSuperview];
    
    if (!_navView) {
        _navView = [[UIView alloc] initWithFrame:CGRectMake(0 , 0, kWindowW, k_Height_NavBar)];
        _navView.backgroundColor = [UIColor whiteColor];
        [self.view addSubview:_navView];
        
        UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
        backButton.frame = CGRectMake(0, k_Height_NavBar - 40, 35, 35);
        [backButton addTarget:self action:@selector(popButtonClicked) forControlEvents:UIControlEventTouchUpInside];
        [backButton setTitle:@"" forState:UIControlStateNormal];
        [backButton setImage:[UIImage imageNamed:@"back_ black"] forState:UIControlStateNormal];
        [_navView addSubview:backButton];
        
        UILabel *titleLabel = [UILabel new];
        titleLabel.text = title;
        titleLabel.font = [UIFont systemFontOfSize:18];
        titleLabel.textColor = UIColorFromRGB(0x000000);
        [titleLabel setTextAlignment:NSTextAlignmentCenter];
        titleLabel.frame = CGRectMake(50, k_Height_NavBar - 35, kWindowW - 100, 25);
        [_navView addSubview:titleLabel];
        
        if (isLine) {
            UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, k_Height_NavBar - 0.5, kWindowW, 0.5)];
            lineView.backgroundColor = UIColorFromRGB(0xeeeeee);
            [_navView addSubview:lineView];
        }
        
    }
}


- (void)popButtonClicked {
    [self.navigationController popViewControllerAnimated:YES];
}
- (UIStatusBarStyle)preferredStatusBarStyle {

return UIStatusBarStyleLightContent;

}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
